package com.gin.kotlin.no_gay_alliance.utils

import android.util.Log

/**
 * 秒表，用于步骤计时
 */
class LogCounter(val tag: String, val name: String) {
    private var start = 0L
    private var lastStep = 0L

    fun start() {
        this.start = System.currentTimeMillis()
        this.lastStep = this.start
        Log.i(tag, "$name: 计时开始")
    }

    fun step(remark: String) {
        val now = System.currentTimeMillis()
        Log.d(tag, "$name: 计时点:$remark, 本步骤耗时: ${now - lastStep}, 总耗时: ${now - start}")
        this.lastStep = now
    }

    fun stop() {
        val now = System.currentTimeMillis()
        Log.i(tag, "$name: 计时结束, 本步骤耗时: ${now - lastStep}, 总耗时: ${now - start}")
    }
}